//
//  MKHomeNavigationBar.swift
//  MOKOAnnounce
//
//  Created by 曹相召 on 2017/7/11.
//  Copyright © 2017年 cc.moko. All rights reserved.
//  首页导航栏自定义

import UIKit

class MKHomeNavigationBar: UIView {

    var search:UIImageView!
    var tip:UILabel!
    var back:UIView!
    var scan:UIButton!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.makeUI()
    }
    
    func makeUI() -> Void {
        
        self.backgroundColor = UIColorFromRGB(rgbValue: 0xf8f8f8, A: 1)
        
        self.back = UIView.init()
        self.back.backgroundColor = UIColor.white
        self.addSubview(self.back)
        
        self.search = UIImageView.init()
        self.search.image = UIImage.init(named: "chazhao")
        self.back.addSubview(self.search)
        
        self.tip = UILabel.label(fontSize: 14, textColor: UIColorFromRGB(rgbValue: 0xcccccc, A: 1))
        self.tip.text = "点击这里可以精准查找艺人或作品"
        self.back.addSubview(self.tip)
    
        self.scan = UIButton.init()
        self.scan.setImage(UIImage.init(named: "saoyisao"), for: .normal)
        self.addSubview(self.scan)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.scan.frame = CGRect.init(x: self.width - 40, y: 20 + (44 - 30) * 0.5, width: 30, height: 30)
        
        self.back.frame = CGRect.init(x: 15, y: 20 + (44 - 33) * 0.5, width: self.width - 15 - 15 - 10 - 30, height: 33)
        self.back.layer.cornerRadius = 4
        self.back.clipsToBounds = true
        
        self.tip.sizeToFit()
        self.search.frame = CGRect.init(x: (self.back.width - self.tip.width - 17 - 8) * 0.5, y: (self.back.height - 17) * 0.5, width: 17, height: 17)
    
        self.tip.frame = CGRect.init(x: self.search.right + 8, y: (self.back.height - self.tip.height) * 0.5, width: self.tip.width, height: self.tip.height)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
